package scalaLearning.part2

object ConstructorDemo2 {
  def main(args: Array[String]): Unit = {
    println("以下是代码运行顺序：")
    val p1 = new Person2("jacky")
    println("创建完成~")

  }
}

class Person2() extends Person2Dad {
  var name: String = _
  var age: Int = _
  println("这里是主构造器")

  //辅助构造器1
  def this(name: String) {
    this()
    this.name = name
    println("这里是辅助构造器")
  }

  //辅助构造器2
  def this(age: Int) {
    this()
    this.age = age
  }
}

class Person2Dad{
  println("这里是父类主构造器")
}